package com.example.leetcode.niuke;

import java.util.Scanner;

public class NiuKe1 {


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        System.out.println(convert(s));
    }


    private static String convert(String s) {
        if (s == null) {
            return null;
        }
        if (s.length() <= 2) {
            return s;
        }
        StringBuilder sb = new StringBuilder();
        int count = 1;
        char t = s.charAt(0);
        for (int i = 1;i <s.length();i ++) {
            if (s.charAt(i) == t) {
                count++;
            }else {
                if (count > 2) {
                    sb.append(count).append(t);
                }else {
                    if (t == 1) {
                        sb.append(t);
                    }else {
                        sb.append(t).append(t);
                    }
                }
                count =1 ;
                t = s.charAt(i);
            }
        }
        if (count > 2) {
            sb.append(count).append(t);
        } else {
            if (count == 1) {
                sb.append(t);
            }else {
                sb.append(t).append(t);
            }
        }
        return sb.toString();
    }
}
